package com.xu.renji.webapp;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import org.apache.commons.digester.Digester;
import org.xml.sax.SAXException;

public class WorkFlowCfg  extends ArrayList<ModelCfg>{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3828970015092180181L;

	public void load(File configFile)
	
	{
		Digester digester = new Digester();
		digester.push(this);
		digester.addObjectCreate("workFlowCfg/modelCfg", ModelCfg.class);
		digester.addSetNext("workFlowCfg/modelCfg", "add");
		digester.addBeanPropertySetter("workFlowCfg/modelCfg/nodeID");
		
		digester.addObjectCreate("workFlowCfg/modelCfg/settingCfg", SettingCfg.class);
		digester.addSetNext("workFlowCfg/modelCfg/settingCfg", "add");
		digester.addBeanPropertySetter("workFlowCfg/modelCfg/settingCfg/name");
		digester.addBeanPropertySetter("workFlowCfg/modelCfg/settingCfg/scope");
		digester.addBeanPropertySetter("workFlowCfg/modelCfg/settingCfg/type");
		digester.addBeanPropertySetter("workFlowCfg/modelCfg/settingCfg/key");
		
		try {
			digester.parse(configFile);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
//	public static void main(String[] args) {
//		System.out.println("here");
//		WorkFlowCfg cfg = new WorkFlowCfg();
//		cfg.load(new File("D:\\eclipse kmine\\runtime-EclipseApplication\\KNIME_project\\config.xml"));
//		System.out.println(cfg);
//	}
}
